let layer
$(function () {
    layui.use(['layer', 'form', 'element'], function () {
        layer = layui.layer, form = layui.form, element = layui.element;
        $('.order-list').on('click', 'li', function () {
            loadData($(this).attr('data'), $(this).attr('index'))
        })
    })
})

function loadData(tradeStatus, index) {
    location.href = '/order/queryList?tradeStatus=' + tradeStatus + "&index=" + index
}

/**
 * 商品详情
 * @param productId
 */
function querySingle(productId) {
    location.href = api.ProductInfo + '?id=' + productId
}

function queryExpress(id) {
    location.href = api.ExpressInfo + '?orderId=' + id
}

/**
 * 删除订单
 * @param id
 */
function delOrder(id) {
    layer.confirm('确认要删除该订单吗？删除后无法恢复。', {title: '警告框'}, function (index) {
        location.href = api.DeleteOrder + '?id=' + id
    })
}

/**
 * 确认收货
 * @param id
 */
function queryReceiving(id) {
    layer.confirm('确认要删除该订单吗？删除后无法恢复。', {title: '警告框'}, function (index) {
        location.href = api.QueryReceipt + '?id=' + id
    })
}

/**
 * 退款
 * @param id
 */
function refund(id, productId) {
    layer.confirm('该订单确认要退款退货吗？', {title: '警告框'}, function (index) {
        post(api.Refund, {id: id, productId: productId}).then(res => {
            location.reload()
        })
    })
}